{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Configuring pandas"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# import numpy and pandas\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "# used for dates\n",
    "import datetime\n",
    "from datetime import datetime, date\n",
    "\n",
    "# Set formattign options\n",
    "pd.set_option('display.notebook_repr_html', False)\n",
    "pd.set_option('display.max_columns', 7)\n",
    "pd.set_option('display.max_rows', 10)\n",
    "pd.set_option('display.width', 60)\n",
    "\n",
    "# bring in matplotlib for graphics\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "\n",
    "# read in the data and print the first five rows\n",
    "# use the Symbol column as the index, and \n",
    "# only read in columns in positions 0, 2, 3, 7\n",
    "sp500 = pd.read_csv(\"data/sp500.csv\", \n",
    "                    index_col='Symbol', \n",
    "                    usecols=[0, 2, 3, 7])\n",
    "\n",
    "# one month of stock history data\n",
    "omh = pd.read_csv(\"data/omh.csv\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Performing arithmetic on a DataFrame or Series"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "          A         B         C         D\n",
       "0  0.469112 -0.282863 -1.509059 -1.135632\n",
       "1  1.212112 -0.173215  0.119209 -1.044236\n",
       "2 -0.861849 -2.104569 -0.494929  1.071804\n",
       "3  0.721555 -0.706771 -1.039575  0.271860\n",
       "4 -0.424972  0.567020  0.276232 -1.087401"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# set the seed to allow replicatable results\n",
    "np.random.seed(123456)\n",
    "# create the DataFrame\n",
    "df = pd.DataFrame(np.random.randn(5, 4), \n",
    "                  columns=['A', 'B', 'C', 'D'])\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "          A         B         C         D\n",
       "0  0.938225 -0.565727 -3.018117 -2.271265\n",
       "1  2.424224 -0.346429  0.238417 -2.088472\n",
       "2 -1.723698 -4.209138 -0.989859  2.143608\n",
       "3  1.443110 -1.413542 -2.079150  0.543720\n",
       "4 -0.849945  1.134041  0.552464 -2.174801"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# multiply everything by 2\n",
    "df * 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "          A         B         C         D\n",
       "0  0.000000  0.000000  0.000000  0.000000\n",
       "1  0.743000  0.109649  1.628267  0.091396\n",
       "2 -1.330961 -1.821706  1.014129  2.207436\n",
       "3  0.252443 -0.423908  0.469484  1.407492\n",
       "4 -0.894085  0.849884  1.785291  0.048232"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# get first row \n",
    "s = df.iloc[0] \n",
    "# subtract first row from every row of the DataFrame\n",
    "diff = df - s \n",
    "diff"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "          A         B         C         D\n",
       "0  0.000000  0.000000  0.000000  0.000000\n",
       "1 -0.743000 -0.109649 -1.628267 -0.091396\n",
       "2  1.330961  1.821706 -1.014129 -2.207436\n",
       "3 -0.252443  0.423908 -0.469484 -1.407492\n",
       "4  0.894085 -0.849884 -1.785291 -0.048232"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# subtract DataFrame from Series\n",
    "diff2 = s - df\n",
    "diff2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "    A         B         C   D   E\n",
       "0 NaN -0.565727 -3.018117 NaN NaN\n",
       "1 NaN -0.456078 -1.389850 NaN NaN\n",
       "2 NaN -2.387433 -2.003988 NaN NaN\n",
       "3 NaN -0.989634 -2.548633 NaN NaN\n",
       "4 NaN  0.284157 -1.232826 NaN NaN"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# B, C\n",
    "s2 = s[1:3]\n",
    "# add E\n",
    "s2['E'] = 0\n",
    "# see how alignment is applied in math\n",
    "df + s2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "          B         C\n",
       "1 -0.173215  0.119209\n",
       "2 -2.104569 -0.494929\n",
       "3 -0.706771 -1.039575"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# get rows 1 through three, and only B, C columns\n",
    "subframe = df[1:4][['B', 'C']]\n",
    "# we have extracted a little square in the middle of df\n",
    "subframe"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "    A    B    C   D\n",
       "0 NaN  NaN  NaN NaN\n",
       "1 NaN  0.0  0.0 NaN\n",
       "2 NaN  0.0  0.0 NaN\n",
       "3 NaN  0.0  0.0 NaN\n",
       "4 NaN  NaN  NaN NaN"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# demonstrate the alignment of the subtraction\n",
    "df - subframe"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "     A         B         C         D\n",
       "0  0.0 -0.751976 -1.978171 -1.604745\n",
       "1  0.0 -1.385327 -1.092903 -2.256348\n",
       "2  0.0 -1.242720  0.366920  1.933653\n",
       "3  0.0 -1.428326 -1.761130 -0.449695\n",
       "4  0.0  0.991993  0.701204 -0.662428"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# get the A column\n",
    "a_col = df['A']\n",
    "df.sub(a_col, axis=0)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Counts of values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = pd.Series(['a', 'a', 'b', 'c', np.NaN])\n",
    "# number of occurrences of each unique value\n",
    "s.count()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Unique and number of unique values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['a', 'b', 'c', nan], dtype=object)"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# return a list of unique items\n",
    "s.unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.nunique(dropna=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a      2\n",
       "b      1\n",
       "c      1\n",
       "NaN    1\n",
       "dtype: int64"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# get summary stats on non-numeric data\n",
    "s.value_counts(dropna=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Minimum and maximums"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "MSFT     45.16\n",
       "AAPL    106.75\n",
       "dtype: float64"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# location of min price for both stocks\n",
    "omh[['MSFT', 'AAPL']].min()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "MSFT     48.84\n",
       "AAPL    115.93\n",
       "dtype: float64"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# and location of the max\n",
    "omh[['MSFT', 'AAPL']].max()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "MSFT    11\n",
       "AAPL    11\n",
       "dtype: int64"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# location of min price for both stocks\n",
    "omh[['MSFT', 'AAPL']].idxmin()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "MSFT    3\n",
       "AAPL    2\n",
       "dtype: int64"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# and location of the max\n",
    "omh[['MSFT', 'AAPL']].idxmax()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Smallest and Largest Values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "11    45.16\n",
       "12    45.74\n",
       "21    46.45\n",
       "10    46.67\n",
       "Name: MSFT, dtype: float64"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# get the 4 smallest values\n",
    "omh.nsmallest(4, ['MSFT'])['MSFT']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3     48.84\n",
       "0     48.62\n",
       "1     48.46\n",
       "16    48.45\n",
       "Name: MSFT, dtype: float64"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# get the 4 largest values\n",
    "omh.nlargest(4, ['MSFT'])['MSFT']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "11    45.16\n",
       "12    45.74\n",
       "21    46.45\n",
       "10    46.67\n",
       "Name: MSFT, dtype: float64"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# nsmallest on a Series\n",
    "omh.MSFT.nsmallest(4)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Accumulations"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     1\n",
       "1     2\n",
       "2     6\n",
       "3    24\n",
       "dtype: int64"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# calculate a cumulative product\n",
    "pd.Series([1, 2, 3, 4]).cumprod()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     1\n",
       "1     3\n",
       "2     6\n",
       "3    10\n",
       "dtype: int64"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# calculate a cumulative sum\n",
    "pd.Series([1, 2, 3, 4]).cumsum()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Summary descriptive statistics"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "            MSFT        AAPL\n",
       "count  22.000000   22.000000\n",
       "mean   47.493182  112.411364\n",
       "std     0.933077    2.388772\n",
       "min    45.160000  106.750000\n",
       "25%    46.967500  111.660000\n",
       "50%    47.625000  112.530000\n",
       "75%    48.125000  114.087500\n",
       "max    48.840000  115.930000"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# get summary statistics for the stock data\n",
    "omh.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "count    22.000000\n",
       "mean     47.493182\n",
       "std       0.933077\n",
       "min      45.160000\n",
       "25%      46.967500\n",
       "50%      47.625000\n",
       "75%      48.125000\n",
       "max      48.840000\n",
       "Name: MSFT, dtype: float64"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# just the stats for MSFT\n",
    "omh.MSFT.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "47.493181818181817"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# only the mean for MSFT\n",
    "omh.MSFT.describe()['mean']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "count     4\n",
       "unique    3\n",
       "top       a\n",
       "freq      2\n",
       "dtype: object"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# get summary stats on non-numeric data\n",
    "s = pd.Series(['a', 'a', 'b', 'c', np.NaN])\n",
    "s.describe()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Mean"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "MSFT     47.493182\n",
       "AAPL    112.411364\n",
       "dtype: float64"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# the mean of all the columns in omh\n",
    "omh.mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    81.845\n",
       "1    81.545\n",
       "2    82.005\n",
       "3    82.165\n",
       "4    81.710\n",
       "dtype: float64"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# calc the mean of the values in each row\n",
    "omh.mean(axis=1)[:5]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Median"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "MSFT     47.625\n",
       "AAPL    112.530\n",
       "dtype: float64"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# calc the median of the values in each column\n",
    "omh.median()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Mode"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    3\n",
       "dtype: int64"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# find the mode of this Series\n",
    "s = pd.Series([1, 2, 3, 3, 5])\n",
    "s.mode()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    1\n",
       "1    3\n",
       "dtype: int64"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# there can be more than one mode\n",
    "s = pd.Series([1, 2, 3, 3, 5, 1])\n",
    "s.mode()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Variance"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "MSFT    0.870632\n",
       "AAPL    5.706231\n",
       "dtype: float64"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# calc the variance of the values in each column\n",
    "omh.var()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Standard Deviation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "MSFT    0.933077\n",
       "AAPL    2.388772\n",
       "dtype: float64"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# standard deviation\n",
    "omh.std()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Covariance"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.9261240259740264"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# covariance of MSFT vs AAPL\n",
    "omh.MSFT.cov(omh.AAPL)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Correlation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.8641560684381171"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# correlation of MSFT relative to AAPL\n",
    "omh.MSFT.corr(omh.AAPL)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Discretization and quantiling"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 0.4691123 , -0.28286334, -1.5090585 , ...,  0.26296448,\n",
       "       -0.83377412, -0.10418135])"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# generate 10000 normal random #'s\n",
    "np.random.seed(123456)\n",
    "dist = np.random.normal(size = 10000)\n",
    "dist"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(-0.0028633240409066509, 1.0087162031998911)"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# show the mean and std\n",
    "(dist.mean(), dist.std())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[(-0.633, 0.81], (-0.633, 0.81], (-2.077, -0.633], (-2.077, -0.633], (0.81, 2.254], ..., (-2.077, -0.633], (-0.633, 0.81], (-0.633, 0.81], (-2.077, -0.633], (-0.633, 0.81]]\n",
       "Length: 10000\n",
       "Categories (5, interval[float64]): [(-3.528, -2.077] < (-2.077, -0.633] < (-0.633, 0.81] < (0.81, 2.254] < (2.254, 3.698]]"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# cut into 5 equally sized bins\n",
    "bins = pd.cut(dist, 5)\n",
    "bins"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "IntervalIndex([(-3.528, -2.077], (-2.077, -0.633], (-0.633, 0.81], (0.81, 2.254], (2.254, 3.698]]\n",
       "              closed='right',\n",
       "              dtype='interval[float64]')"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# just the categories \n",
    "bins.categories"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([2, 2, 1, ..., 2, 1, 2], dtype=int8)"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# codes tells us which bin each item is in\n",
    "bins.codes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "IntervalIndex([[-3.521, -2.077), [-2.077, -0.633), [-0.633, 0.81), [0.81, 2.254), [2.254, 3.705)]\n",
       "              closed='left',\n",
       "              dtype='interval[float64]')"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# move the closed side of the interval to the left\n",
    "pd.cut(dist, 5, right=False).categories"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 7, 33, 38, 29, 42, 14, 16, 16, 18, 17, 26, 28, 44, 40, 20, 12,  8,\n",
       "       10, 36, 29, 26, 26, 11, 29, 42, 17, 41, 35, 22, 40, 24, 21, 38, 33,\n",
       "       26, 23, 16, 34, 26, 20, 18, 42, 27, 13, 37, 37, 10,  7, 10, 23])"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# generate 50 ages between 6 and 45\n",
    "np.random.seed(123456)\n",
    "ages = np.random.randint(6, 45, 50)\n",
    "ages"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "            counts  freqs\n",
       "categories               \n",
       "(6, 12]          8   0.16\n",
       "(12, 18]         9   0.18\n",
       "(18, 35]        21   0.42\n",
       "(35, 50]        12   0.24"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# cut into ranges and then get descriptive stats\n",
    "ranges = [6, 12, 18, 35, 50]\n",
    "agebins = pd.cut(ages, ranges)\n",
    "agebins.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "             counts  freqs\n",
       "categories                \n",
       "Youth             8   0.16\n",
       "Young Adult       9   0.18\n",
       "Adult            21   0.42\n",
       "Middle Aged      12   0.24"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# add names for the bins\n",
    "ranges = [6, 12, 18, 35, 50]\n",
    "labels = ['Youth', 'Young Adult', 'Adult', 'Middle Aged']\n",
    "agebins = pd.cut(ages, ranges, labels=labels)\n",
    "agebins.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "                  counts  freqs\n",
       "categories                     \n",
       "(-3.522, -0.861]    2000    0.2\n",
       "(-0.861, -0.241]    2000    0.2\n",
       "(-0.241, 0.261]     2000    0.2\n",
       "(0.261, 0.866]      2000    0.2\n",
       "(0.866, 3.698]      2000    0.2"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# cut into quantiles\n",
    "# 5 bins with an equal quantity of items\n",
    "qbin = pd.qcut(dist, 5)\n",
    "# this will tell us the range of values in each quantile\n",
    "qbin.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "                    counts  freqs\n",
       "categories                       \n",
       "(-3.522, -3.131]        10  0.001\n",
       "(-3.131, -2.056]       200  0.020\n",
       "(-2.056, -1.033]      1380  0.138\n",
       "(-1.033, -0.00363]    3410  0.341\n",
       "(-0.00363, 1.011]     3410  0.341\n",
       "(1.011, 2.043]        1380  0.138\n",
       "(2.043, 3.062]         200  0.020\n",
       "(3.062, 3.698]          10  0.001"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# make the quantiles at the +/- 3, 2 and 1 std deviations\n",
    "quantiles = [0,\n",
    "             0.001, \n",
    "             0.021,\n",
    "             0.5-0.341,\n",
    "             0.5,\n",
    "             0.5+0.341,\n",
    "             1.0-0.021,\n",
    "             1.0-0.001,\n",
    "             1.0]\n",
    "qbin = pd.qcut(dist, quantiles)\n",
    "# this data should be a perfect normal distribution\n",
    "qbin.describe()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Ranking"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a   -0.204708\n",
       "b    0.478943\n",
       "c   -0.519439\n",
       "d   -0.555730\n",
       "e    1.965781\n",
       "dtype: float64"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# random data\n",
    "np.random.seed(12345)\n",
    "s = pd.Series(np.random.np.random.randn(5), index=list('abcde'))\n",
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "a    3.0\n",
       "b    4.0\n",
       "c    2.0\n",
       "d    1.0\n",
       "e    5.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# rank the values\n",
    "s.rank()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Percent change"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "       MSFT\n",
       "0       NaN\n",
       "1 -0.003291\n",
       "2 -0.007842\n",
       "3  0.015807\n",
       "4 -0.008600"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# calculate % change on MSFT\n",
    "omh[['MSFT']].pct_change()[:5]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Moving window operations"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    0.469112\n",
       "1    0.186249\n",
       "2   -1.322810\n",
       "3   -2.458442\n",
       "4   -1.246330\n",
       "dtype: float64"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# create a random walk\n",
    "np.random.seed(123456)\n",
    "s = pd.Series(np.random.randn(1000)).cumsum()\n",
    "s[:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD8CAYAAAB0IB+mAAAABHNCSVQICAgI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8nTVazFRDhH4\nSikj8AdgLZABfEYplWHfVk2rHuBbWusMYAnwlb7v/zFgm9Y6FdjW97UreRQ4dcnXrnw9fgds1lrP\nBDKxXBeXux5KqRjg60C21noOYATuwgWvxWQ4ROADi4BCrXWx1roLeAnYYOc2TRut9Tmt9aG+z5ux\n/GeOwXIN/tq321+BT9mnhdNPKRULrAOeuWSzS14PpVQAcCXwLIDWuktrfQEXvR5Ynh/yUkqZAG+g\nEte9FhPiKIEfA5Rd8nV53zaXo5RKBOYD+4AIrfW5vpeqgAg7Ncsefgt8FzBfss1Vr0cSUAs811fi\nekYp5YMLXg+tdQXwS+AscA5o1Fq/jwtei8lwlMAXgFLKF3gN+IbWuunS17RlOJVLDKlSSt0E1Git\nD460jytdDyw92gXAH7XW84FWPlGycJXr0Veb34Dlh2A04KOU+uyl+7jKtZgMRwn8CiDukq9j+7a5\nDKWUG5aw/7vW+vW+zdVKqai+16OAGnu1b5otB9YrpUqwlPeuUUq9gOtej3KgXGu9r+/rV7H8AHDF\n67EGOKO1rtVadwOvA8twzWsxYY4S+PuBVKVUklLKHctNmE12btO0UUopLPXZU1rrX1/y0ibgc32f\nfw54c7rbZg9a68e11rFa60Qs/xY+0Fp/Fte9HlVAmVIqvW/TauAkrnk9zgJLlFLeff9vVmO55+WK\n12LCHObBK6XUjVjqtkbgz1rrn9i5SdNGKbUC2AUc42LN+l+x1PFfBuKBUuAOrfV5uzTSTpRSq4Bv\na61vUkqF4KLXQymVheUGtjtQDNyPpcPmctdDKfVj4E4so9sOAw8AvrjgtZgohwl8IYQQtuUoJR0h\nhBA2JoEvhBAuQgJfCCFchAS+EEK4CAl8IYRwERL4QgjhIiTwhRDCRUjgCyGEi/j/CQYthk3qIooA\nAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x10b0a4518>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "s[0:100].plot();"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Rolling [window=3,center=False,axis=0]"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# calculate rolling window of three days\n",
    "r = s.rolling(window=3)\n",
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0         NaN\n",
       "1         NaN\n",
       "2   -0.222483\n",
       "3   -1.198334\n",
       "4   -1.675860\n",
       "5   -1.708105\n",
       "6   -1.322070\n",
       "dtype: float64"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# the rolling mean at three days\n",
    "means = r.mean()\n",
    "means[:7]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-0.22248276403642672"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# check the mean of the first 3 numbers\n",
    "s[0:3].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-1.1983341702095498"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# mean of 1 through 3\n",
    "s[1:4].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAD8CAYAAABzTgP2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xd4VGX2wPHvSS+EQEIqgUAgtNCESLHRRVkFy9p+tnVV\n1l5W17Xsum53i7rNBq4uNqw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gAIB24ico//trq/fgtcBWVvfnWALcA7Wij96MxPCoxGGOMcT1PqkoyxhjTAiwxGGOM\nqcYSgzHGmGosMRhjjKnGEoMxxphqLDEYY4ypxhKDMcaYaiwxGGOMqeb/AVX/lUBF11RGAAAAAElF\nTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x101dfbac8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# plot the 3 day rolling mean\n",
    "means[0:100].plot();"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Random sampling"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "          0         1         2         3\n",
       "0  0.469112 -0.282863 -1.509059 -1.135632\n",
       "1  1.212112 -0.173215  0.119209 -1.044236\n",
       "2 -0.861849 -2.104569 -0.494929  1.071804\n",
       "3  0.721555 -0.706771 -1.039575  0.271860\n",
       "4 -0.424972  0.567020  0.276232 -1.087401"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# create a random sample of four columns of 50 items\n",
    "np.random.seed(123456)\n",
    "df = pd.DataFrame(np.random.randn(50, 4))\n",
    "df[:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "           0         1         2         3\n",
       "15 -0.076467 -1.187678  1.130127 -1.436737\n",
       "28 -2.182937  0.380396  0.084844  0.432390\n",
       "48 -0.693921  1.613616  0.464000  0.227371"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# sample three random rows\n",
    "df.sample(n=3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "           0         1         2         3\n",
       "37  1.126203 -0.977349  1.474071 -0.064034\n",
       "10 -1.294524  0.413738  0.276662 -0.472035\n",
       "4  -0.424972  0.567020  0.276232 -1.087401\n",
       "14  0.410835  0.813850  0.132003 -0.827317\n",
       "48 -0.693921  1.613616  0.464000  0.227371"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# sample 10% of the rows\n",
    "df.sample(frac=0.1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "           0         1         2         3\n",
       "27 -1.236269  0.896171 -0.487602 -0.082240\n",
       "9   0.357021 -0.674600 -1.776904 -0.968914\n",
       "27 -1.236269  0.896171 -0.487602 -0.082240\n",
       "15 -0.076467 -1.187678  1.130127 -1.436737\n",
       "9   0.357021 -0.674600 -1.776904 -0.968914"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 10% with replacement\n",
    "df.sample(frac=0.1, replace=True)"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
